<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>客户管理</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/weui/weui.min.css">
    <link rel="stylesheet" href="/static/weui/default.css"/>
</head>
<body>

<!--BEGIN dialog1-->
<div role="dialog" aria-hidden="true" aria-modal="true" aria-labelledby="js_title1" id="msgDialog" style="display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__hd"><strong class="weui-dialog__title" id="js_title1">操作确认</strong></div>
        <div class="weui-dialog__bd">{{ name }}，{{ errormsg }}，需要新增吗？</div>
        <div class="weui-dialog__ft">
            <a role="button" href="javascript:" class="weui-dialog__btn weui-dialog__btn_default" id="msgDialogCancel">取消</a>
            <a role="button" href="/client/client/add?name={{ name }}" id="msgDialogConfirm"
               class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
        </div>
    </div>
</div>
<!--END dialog1-->

<!-- -->
<form class="page" method="post" id="form" onsubmit="formSubmit()">
    <div class="weui-form">
        <div class="weui-form__bd">
            {% csrf_token %}
            <div class="weui-form__text-area">
                <h2 class="weui-form__title">客户搜索</h2>
            </div>
            <div class="weui-form__control-area">
                <div class="weui-cells__group weui-cells__group_form">
                    <div class="weui-cells card">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <input class="weui-input" type="text" required pattern="REG_NAME"
                                       placeholder="输入客户全称" emptyTips="请输入客户全称"
                                       notMatchTips="请输入正确的客户全称">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="weui-form__control-area">
                <div class="weui-form__opr-area">
                    <!--
                    <a role="button" class="weui-btn weui-btn_primary" id="testModel">测试MODEL</a>
                    -->
                    <input role="button" class="weui-btn weui-btn_primary" type="submit"></input>
                </div>
            </div>
        </div>
        <div class="weui-form__ft">
            <div class="weui-form__extra-area">
                <div class="weui-footer">
                    <p class="weui-footer__text">Copyright © 2024 政企客户管理</p>
                </div>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="/static/weui/jquery.min.js"></script>
<script type="text/javascript" src="/static/weui/weui.min.js"></script>
<script type="text/javascript" src="/static/weui/jweixin-1.0.0.js"></script>
<script type="text/javascript">
    $(function () {
        var $msgDialog = $('#msgDialog');
        $('#msgDialogCancel').on('click', function () {
            $msgDialog.fadeOut(200);
            $msgDialog.attr('aria-hidden', 'true');
        });
        $('#msgDialogConfirm').on('click', function () {
            $msgDialog.fadeOut(200);
            $msgDialog.attr('aria-hidden', 'true');
        });
        $('#testModel').on('click', function () {
            $msgDialog.fadeIn(200);
            $msgDialog.attr('aria-hidden', 'false');
            $msgDialog.trigger('focus');
        });
    });
</script>
<script type="text/javascript">
    function formSubmit() {
        console.log("formSubmit")
        weui.form.validate('#form', function (error) {
            if (!error) {
                var loading = weui.loading('提交中...');
                $('#form').submit();
            }
        }, {
            regexp: {
                NAME: /^[\u4E00-\u9FA5]{2,40}$/,
            }
        });
    }
</script>
</body>
</html>
